import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { ArticleForm, ArticlePage, ArticleQuery } from "./types";

/**
 * 获取分页列表
 *
 * @param queryParams
 */
export function getArticlePage(
  queryParams: ArticleQuery
): AxiosPromise<PageResult<ArticlePage[]>> {
  return request({
    url: "/admin/wechatArticle/index",
    method: "get",
    params: queryParams,
  });
}

/**
 * 获取表单详情
 *
 * @param ids
 */
export function getArticleForm(ids: number): AxiosPromise<ArticleForm> {
  return request({
    url: "/admin/wechatArticle/edit",
    method: "get",
    params: {
      ids: ids,
    },
  });
}

/**
 * 添加
 *
 * @param data
 */
export function addArticle(data: any) {
  return request({
    url: "/admin/wechatArticle/add",
    method: "post",
    data: data,
  });
}

/**
 * 修改
 *
 * @param id
 * @param data
 */
export function updateArticle(data: LabelForm) {
  return request({
    url: "/admin/wechatArticle/edit",
    method: "put",
    data: data,
  });
}

/**
 * 删除
 *
 * @param data
 */
export function deleteArticle(data: any) {
  return request({
    url: "/admin/wechatArticle/del",
    method: "delete",
    data,
  });
}

/**
 * 发布微信公众号文章
 *
 * @param data
 */
export function pushArticle(data: any) {
  return request({
    url: "/admin/wechatArticle/push",
    method: "put",
    data,
  });
}

